package com.vodone.v1pin.brand.service
{
	import com.vodone.v1pin.ServiceProvider;
	import com.vodone.v1pin.brand.view.BrandGroup;
	import com.vodone.v1pin.brand.vo.BrandGroupVO;
	import com.vodone.v1pin.brand.vo.BrandItemVO;
	import com.vodone.v1pin.core.service.HttpJsonDelegate;
	
	import flash.utils.setTimeout;
	
	import mx.collections.ArrayCollection;
	import mx.rpc.http.mxml.HTTPService;
	
	public class BrandListDelegate
	{
		public function BrandListDelegate()
		{
		}
		
		public static var aList:Array = [
			"A","B","C","D","E","F","G","H","I","G","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"
		];
		public static var tList:Array = ["热门","奢侈大牌","时装", "配饰","鞋靴","箱包","手表","珠宝"];
		/**
		 * 0:分类 1：字母
		 */		
		CONFIG::isReal
		public static function getBrandList( resultHandler:Function , type:int , faultHandler:Function = null , context:Array = null ):void
		{
			var service:HTTPService = ServiceProvider.getInstance().getBrandListService;
			var params:Object = {
				type:type
			}
			
			var delegate:HttpJsonDelegate = new HttpJsonDelegate( service );
			delegate.send( params , resultHandler , faultHandler ,context );
		}
		CONFIG::isMock
		public static function getBrandList( resultHandler:Function , type:int , faultHandler:Function = null  , context:Array = null):void
		{
			var brandList:Array = [];
			var list:Array = type == 0 ? tList : aList;
			for( var i:int = 0 ;i < list.length ; i++  )
			{
				var arr:Array = [];
				for( var j:int = 0 ; j < 20 ; j++ )
				{
					var brandItem:BrandItemVO = new BrandItemVO({
						brandid:"",
						ename:"Gucci",
						cname:"古琦",
						initial:list[i]
					});
					arr.push( brandItem );
				}
				var brandGroup:BrandGroupVO = new BrandGroupVO({
					columnID:"",
					columnName:list[i]
				});
				brandGroup.list = new ArrayCollection( arr );
				brandList.push( brandGroup );
			}
			setTimeout( resultHandler , 500 , {data:new ArrayCollection(brandList)} , type  );
		}
	}
}